#pragma once

#include <pthread.h>

class Lock
{
public:
    Lock(pthread_mutex_t* pmutex):_pmutex(pmutex)
    {}

    ~Lock() {}

    void lock()
    {
        pthread_mutex_lock(_pmutex);
    }

    void unlock()
    {
        pthread_mutex_unlock(_pmutex);
    }
private:
    pthread_mutex_t* _pmutex;
};

class LockGuard
{
public:
    LockGuard(pthread_mutex_t* pmutex):_pmutex(pmutex)
    {
        _pmutex.lock();
    }

    ~LockGuard()
    {
        _pmutex.unlock();
    }
private:
    Lock _pmutex;
};